/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package orest.common.dao;
import java.sql.*;
import orest.common.response.*;
import orest.common.util.DataBase;
import java.util.ArrayList;
import orest.common.valueobject.KjcgKeyVal;
/**
 *
 * @author admin
 */
public class KjcgKeyDao {
    
    public KjcgKeyDao() {
    }

   

     public boolean findKjcgKeyByPrk(Response rp,String id) {
       boolean result = true;
        ArrayList al = new ArrayList();

        /* dao object begin */
        ResultSet rs = null;
        PreparedStatement pstmt = null;
        Connection conn = null;
        DataBase db = new DataBase();
        /* dao object end */

        /* sql string begin */
        String sql = "select * from  T_KjcgKey where  KjcgID='" + id +"'";
        sql += " order by SortID";
// System.out.println(sql);
        /* sql string end */


        try{
            conn = db.getSysConnectionPool();
            pstmt = conn.prepareStatement (sql);
            rs = pstmt.executeQuery ();
            while(rs.next ()){
                 al.add (new KjcgKeyVal(
                                     rs.getString ("KjcgID"),
                                     rs.getString("Keyword"),
                                     rs.getString("SortID"),
                                     rs.getString("IfHighFrequency"),
                                     rs.getInt("AppearTimes")
                                    ));
                 
            }
            rp.setValObjs (al);
            return result;
          
        }
       catch(SQLException e){
            e.printStackTrace();
            result = false;
            return result;
        }
        catch(Exception e){
            e.printStackTrace();
            result = false;
            return result;
        }
        finally{
            /* close the statement */
            if(null != pstmt){
                try{
                    pstmt.close ();
                    pstmt = null;
                }
                catch(SQLException e){
                	e.printStackTrace();
                }
            }

            /* release the conn */
            if(null != conn){
                try{
                    conn.close();
                    conn = null;
                    db = null;
                }
                catch(Exception e){
                	e.printStackTrace();
                }
            }
        }
    }




}
